package vn.sunnet.game.SinhTon.object;

import vn.sunnet.game.SinhTon.global.Assets;

import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.Actor;

// Cang cua ben trai con Boss10
public class NipperLeft extends Actor {
	private float stateTime;
	private int stateNipper;
	private Animation aniLeftNipper, aniNipperDie;
	private TextureRegion texture;
	private Rectangle bounds;

	public NipperLeft() {
		aniLeftNipper = Assets.atNipperLeft;
		aniNipperDie = Assets.atNipperDie;
		texture = aniLeftNipper.getKeyFrame(stateTime, true);
		bounds = new Rectangle(getX() - 25, getY(), 82, 80);
	}

	@Override
	public void draw(SpriteBatch batch, float parentAlpha) {
		batch.draw(texture, getX() - 25, getY(), getWidth(), getHeight());
	}

	private void update(float delta) {
		switch (getStateNipper()) {
		case 0:
			this.bounds.x = getX() - 25;
			this.bounds.y = getY();
			texture = aniLeftNipper.getKeyFrame(stateTime, true);
			break;
		case 1:
			clearActions();		
			texture = aniNipperDie.getKeyFrame(stateTime, true);
			bounds.x = 0; bounds.y = 0;
			bounds.width= 0; bounds.height = 0;
			break;
		}
	}

	public Rectangle getBounds(){
		return bounds;
	}
	@Override
	public void act(float delta) {
		super.act(delta);
		stateTime += delta;
		update(delta);
	}

	public int getStateNipper() {
		return stateNipper;
	}

	public void setStateNipper(int stateNipper) {
		this.stateNipper = stateNipper;
	}

}
